#include "CSocketServer.h"
#include "CSocketClientManager.h"

CSocketServer::CSocketServer():m_pSocketListener(new CSocketListener), m_pSocketClientManager(new CControlClientManager)
{
}
CSocketServer::~CSocketServer()
{
	CloseServer();
}

int CSocketServer::InitServer(ST_SERVERINFO_OBJ serverInfoObj)
{
	return m_pSocketListener->InitListener(serverInfoObj);
}
int CSocketServer::StartServer()
{
	return m_pSocketListener->StartListener(m_pSocketClientManager);
}
int CSocketServer::GetSocketError()
{
	return m_pSocketListener->GetSocketError();
}
void CSocketServer::CloseServer()
{
	if (m_pSocketListener) {
		m_pSocketListener->CloseListener();
		delete m_pSocketListener;
		m_pSocketListener = nullptr;
	}
	if (m_pSocketClientManager)
	{
		m_pSocketClientManager->CloseAllServer();
		delete m_pSocketClientManager;
		m_pSocketClientManager = nullptr;
	}
}
